<?php


global $config;
echo '
<html>
<head>
	<title></title>
	<META http-equiv=Content-Type content="text/html; charset=UTF-8">
	<META http-equiv="cache-control" content="no-cache">
	<META http-equiv="pragma" content="no-cache">
	<META name="author" content="Adam Fišer (Wanex.cz)">
	<META name="url" content="http://www.wanex.cz">
	<META name="copyright" content="Copyright 2008">
	<link rel="stylesheet" href="'.$config["cesta"]["url"].'css/main.css" type="text/css" media="all" />
';

//Kalendar
if($show["Calendar"] == TRUE) {

    echo '    
    <style type="text/css">@import url('.$config["cesta"]["url"].'plugins/jscalendar/calendar-wasys.css);</style>
    <script type="text/javascript" src="'.$config["cesta"]["url"].'plugins/jscalendar/calendar.js"></script>
    <script type="text/javascript" src="'.$config["cesta"]["url"].'plugins/jscalendar/lang/calendar-cs-utf8.js"></script>
    <script type="text/javascript" src="'.$config["cesta"]["url"].'plugins/jscalendar/calendar-setup.js"></script>';
    
}

$WysiwygZaklad = '
    <script language="javascript" type="text/javascript" src="'.$config["cesta"]["url"].'plugins/tiny_mce/tiny_mce.js"></script>
    <script language="javascript" type="text/javascript">
    tinyMCE.init({
        language : "cs",
        mode : "textareas",
        entity_encoding : "raw",';

$WysiwygKonec = '
    });
    </script>';

switch($WysiwygTyp){
    case "poznamka":
        $WysiwygObsah = '
        theme : "advanced",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_layout_manager : "SimpleLayout",
        theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,removeformat,separator,code",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : ""';
    break;
    case "clanek":
        $WysiwygObsah = '
        convert_urls : false,
        plugins : "table, advimage, ibrowser",
        theme : "advanced",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_layout_manager : "SimpleLayout",
        theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,separator,forecolor,image,separator,charmap,removeformat,separator,code",
        theme_advanced_buttons2 : "fontsizeselect,separator,tablecontrols",
        theme_advanced_buttons3 : "ibrowser"';
    break;
}

if(isset($WysiwygTyp)) {
    echo $WysiwygZaklad.$WysiwygObsah.$WysiwygKonec;
}

//Multiple upload file
if($show["multipleUpload"] == TRUE) {
    echo '<script language="javascript" type="text/javascript" src="'.$config["cesta"]["url"].'js/multifile.js"></script>';
}

//Pokud budeme chtit zobrazit google mapu
if($show["GoogleMap"] == true) {
	$priznakBody = ' onload="load()" onunload="GUnload()"';
 	//echo '<link rel="stylesheet" href="'.$config["cesta"]["url"].'css/gsearch.css" type="text/css" media="all" />';
 	//echo '<link rel="stylesheet" href="'.$config["cesta"]["url"].'css/gmlocalsearch.css" type="text/css" media="all" />';
 	
?>


	<style type="text/css">
      @import url("http://www.google.com/uds/css/gsearch.css");
      @import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
      }
    </style>
	<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $config["googleMapsApiKey"]; ?>" type="text/javascript"></script>
	<script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0" type="text/javascript"></script>
    <script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>
   
    
    <script type="text/javascript">
var mArray = Array();
var map;
var centerPoint = new GLatLng(49.817492, 15.472962);

//zelezna ikona pro novy predmet
var zeliIcon = new GIcon(G_DEFAULT_ICON);
zeliIcon.image = "<?php echo $config["cesta"]["url"].'img/greenmark.png'; ?>";
markerOptions = { icon:zeliIcon };

function load() {
	doLoad();
	<?php echo getPointsJS(); ?>
	addMarkers();
}

function doLoad() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.setCenter(centerPoint, 7);
		map.addControl(new GScaleControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		
		
			
		// vyhledavaci form v mape
		map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
				<?php
if(!$show["GoogleMapShowOnly"]) {
	?>
		GEvent.addListener(map, 'click', mapClick);
		<?php
}
?>
	}
}
GSearch.setOnLoadCallback(doLoad);

function addMarkers() {
	if (mArray.length) {
		var bounds = new GLatLngBounds();
		for (n=0 ; n < mArray.length ; n++ ) {
			var mData = mArray[n].split(';');
			var point = new GLatLng(mData[0],mData[1]);
			bounds.extend(point);
			var marker = createMarker(point, mData[2], mData[3]);
			map.addOverlay(marker);
		}
		//pokud je zancek mene jak 10, nechame zobrazit celou republiku
		if(mArray.length < 10) {
			map.setCenter(centerPoint,7);
		} else { 
			map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
		}
	}
}

function createMarker(point, title, idPredmetu) {
	var marker = new GMarker(point,{title:title});
	GEvent.addListener(marker, "click", function() {
		//marker.openInfoWindowHtml('<div style="width:250px;"><b>' + title + '</b><hr>Lat: ' + point.y + '<br>Lon: ' + point.x + '</div>');
		marker.openInfoWindowHtml('<div ><h3 id="GM">' + title + '</h3><a href="<?php echo ''.$config["cesta"]["url"].'evidence/predmet/'; ?>' + idPredmetu + '.htm">zobrazit</a></div>');
	});
	return marker;
}

function mapClick(marker, point) {
	
		var aktZoom = map.getZoom();
		var point = new GLatLng(point.y, point.x);
	
	if (!marker) {
		oLat = document.getElementById("lat");
		oLat.value = point.y;
		oLon = document.getElementById("lon");
		oLon.value = point.x;
		oDesc = document.getElementById("nazevPredmetu");
		oDesc.value = 'Nová značka';
		

		
		//smazani uzivatelske znacky a prekresleni
		map.clearOverlays();
		//vlozeni uzivatelske znacky po kliknuti
		map.addOverlay(new GMarker(point, markerOptions) );
		map.setCenter(point,aktZoom);
		addMarkers();

		
	}
}


function toggleZoom(isChecked) {
      if (isChecked) {
        map.enableScrollWheelZoom();
      } else {
        map.disableScrollWheelZoom();
      }
}

</script>
    
<?php

}

if($show["CheckLogin"]) {
	echo '<script type="text/javascript" src="'.$config["cesta"]["url"].'/js/ajax.js"></script>';
	?>

<script>
// sha2fet ajaxeye
var hand = function(str){
	window.document.getElementById('response_span').innerHTML=str;
}
function validateUsername(user){
	var strDomain='';
	window.document.getElementById('response_span').innerHTML="Ověřuji...";
	var ajax = new Ajax();
	ajax.doGet('<?php echo $config["cesta"]["url"]; ?>js/ajax-test.php?action=overUsername&username='+user,hand,'text');
}
</script>

<?php

}

echo '
</head>
<body'.$priznakBody.'>
';
?>